package parser;

import antlr.*;

import java.io.InputStream;
import java.io.Reader;

public class CodeReviewJavaLexer extends JavaLexer {
    public CodeReviewJavaLexer(InputStream in) {
        super(in);
    }

    public CodeReviewJavaLexer(Reader in) {
        super(in);
    }

    public CodeReviewJavaLexer(InputBuffer ib) {
        super(ib);
    }

    public CodeReviewJavaLexer(LexerSharedInputState state) {
        super(state);
    }

    public int index = 0;

    public void consume() throws CharStreamException {
        super.consume();

        //if (this.LA(1) == '\r'){nor++;}
        //if (this.LA(1) == '\n'){non++;}
        index++;
    }

    public Token nextToken() throws TokenStreamException {
        //System.out.println("\n"+localIndex);
        Token tmp = super.nextToken();
        CodeReviewToken crt = (CodeReviewToken) tmp;
        if (crt.getText() != null) {
            //System.out.println(nor + " - " + non);
            //crt.setStartIndexOnMatrix(index - crt.getText().length()-nor);
            //crt.setEndIndex(index-nor);
            crt.setStartIndex(index - crt.getText().length());
//            crt.setEndIndex(index - 1);
            //System.out.println(crt.getText() + ": " + crt.getText().length());
            //System.out.println(index);
            //nor=0;non=0;
            //System.out.println(crt.getText() + "-" + crt.getStartIndexOnMatrix() + "- " + crt.getEndIndex());
        }

        if (crt.getType() == Token.EOF_TYPE) {
            index = 0;
        }
        return crt;
    }
}
	